package com.zhuxulin.nokia;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;

class Order {
	private String orderId;
	private String orderDate;
	private String winningDate;
	private String company;
	private String number1;
	private String number2;
	private String number3;
	private String number4;
	private String number5;
	private String aggregateAmount;

	public String getCompany() {
		return this.company;
	}

	public void setCompany(String company) {
		this.company = company;
	}

	public String getNumber1() {
		return this.number1;
	}

	public void setNumber1(String number1) {
		this.number1 = number1;
	}

	public String getNumber2() {
		return this.number2;
	}

	public void setNumber2(String number2) {
		this.number2 = number2;
	}

	public String getNumber3() {
		return this.number3;
	}

	public void setNumber3(String number3) {
		this.number3 = number3;
	}

	public String getNumber4() {
		return this.number4;
	}

	public void setNumber4(String number4) {
		this.number4 = number4;
	}

	public String getNumber5() {
		return this.number5;
	}

	public void setNumber5(String number5) {
		this.number5 = number5;
	}

	public String getOrderId() {
		return this.orderId;
	}

	public void setOrderId(String orderId) {
		this.orderId = orderId;
	}

	public String getOrderDate() {
		return this.orderDate;
	}

	public void setOrderDate(String orderDate) {
		this.orderDate = orderDate;
	}

	public String getWinningDate() {
		return this.winningDate;
	}

	public void setWinningDate(String winningDate) {
		this.winningDate = winningDate;
	}

	public String getAggregateAmount() {
		return this.aggregateAmount;
	}

	public void setAggregateAmount(String aggregateAmount) {
		this.aggregateAmount = aggregateAmount;
	}

	public byte[] serialize() throws IOException {
		ByteArrayOutputStream baos = new ByteArrayOutputStream();
		DataOutputStream dos = new DataOutputStream(baos);
		dos.writeUTF(this.orderId);
		dos.writeUTF(this.orderDate);
		dos.writeUTF(this.winningDate);
		dos.writeUTF(this.company);
		dos.writeUTF(this.number1);
		dos.writeUTF(this.number2);
		dos.writeUTF(this.number3);
		dos.writeUTF(this.number4);
		dos.writeUTF(this.number5);
		dos.writeUTF(this.aggregateAmount);
		baos.close();
		dos.close();
		return baos.toByteArray();
	}

	public static Order deserialize(byte[] data) throws IOException {
		ByteArrayInputStream bais = new ByteArrayInputStream(data);
		DataInputStream dis = new DataInputStream(bais);
		Order word = new Order();
		word.orderId = dis.readUTF();
		word.orderDate = dis.readUTF();
		word.winningDate = dis.readUTF();
		word.company = dis.readUTF();
		word.number1 = dis.readUTF();
		word.number2 = dis.readUTF();
		word.number3 = dis.readUTF();
		word.number4 = dis.readUTF();
		word.number5 = dis.readUTF();
		word.aggregateAmount = dis.readUTF();
		bais.close();
		dis.close();
		return word;
	}

	public String toString() {
		return "Order{orderId=" + this.orderId + ", orderDate=" + this.orderDate + ", winningDate=" + this.winningDate + ", company=" + this.company
				+ ", number1=" + this.number1 + ", number2=" + this.number2 + ", number3=" + this.number3 + ", number4=" + this.number4
				+ ", number5=" + this.number5 + ", aggregateAmount=" + this.aggregateAmount + '}';
	}
}